﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectSem3
{
    public partial class WebForm10 : System.Web.UI.Page
    {
        private DataClassesHeaxlthDataContext dc = new DataClassesHeaxlthDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (!Page.IsPostBack)
            {
                Bind();
            }
            
        }

        public void Bind()
        {
            var policy = this.dc.policies.Join(this.dc.HospitalInfos, h => h.hospitalid, p => p.hospitalid, (h, p) => new
            {
                h.policyid,
                h.policyname,
                h.policydesc,
                h.amount,
                h.emi,
                p.hospitalname,
                p.hospitalid
            });
            this.GridView1.DataSource = policy.OrderByDescending(a => a.policyid);
            this.GridView1.DataBind();
        }
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            Bind();
        }
    }
}